//-----------------------------------------------------------------------
// <copyright file="DirectorService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class DirectorService
    {
        #region Director

        public static void CreateDirector(Director director)
        {            
            try
            {
                DirectorDAO directorDAO = new DirectorDAO();
                directorDAO.CreateDirector(director);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateDirectorException, ex);
            }
        }        

        public static void UpdateDirector(Director director)
        {            
            try
            {
                DirectorDAO directorDAO = new DirectorDAO();
                directorDAO.UpdateDirector(director);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateDirectorException, ex);
            }
        }        

        public static void DeleteDirector(long directorId)
        {            
            try
            {
                DirectorDAO directorDAO = new DirectorDAO();
                directorDAO.DeleteDirector(directorId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteDirectorException, ex);
            }
        }
        
        public static Director GetDirector(long directorId)
        {            
            try
            {
                DirectorDAO directorDAO = new DirectorDAO();
                return directorDAO.GetDirector(directorId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetDirectorException, ex);
            }
        }                

        public static DirectorCollection GetDirectorList(DirectorColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                DirectorDAO directorDAO = new DirectorDAO();
                return directorDAO.GetDirectorList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetDirectorListException, ex);
            }
        }        

        public static DirectorCollection GetDirectorList(DirectorColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                DirectorDAO directorDAO = new DirectorDAO();
                return directorDAO.GetDirectorList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetDirectorListException, ex);
            }
        }        

	    public static DirectorCollection GetDirectorListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                DirectorDAO directorDAO = new DirectorDAO();
                return directorDAO.GetDirectorListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetDirectorListException, ex);
            }
        }        

        public static DirectorCollection GetDirectorListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                DirectorDAO directorDAO = new DirectorDAO();
                return directorDAO.GetDirectorListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetDirectorListException, ex);
            }
        }        

        #endregion
    }
}